let {
    system
} = require("./system_schema.js");
let {love} = require("../love/love_schema.js");
module.exports = {
    changeMsg: function (req, res, err) {
        let emailData ={
            sendUser:req.body.sendUser,
            addressee:req.body.addressee,
            content:req.body.content,
            // core:req.body.core,
            // _id:req.body._id
        }
        let type = req.body.operaction;

        if(type=="read"){   
            system.updateMany(emailData,{$set:req.body}).then((data)=>{
                //3表示情缘邮件  该邮件有状态
                if(emailData.core==3){
                    love.updateOne({user:emailData.sendUser,toUser:emailData.addressee},{$set:{
                        status:2
                    }}).then((data)=>{
                        console.log(data,1212);
                    })
                }
                console.log(emailData,"email");
                res.send(data);
            })
        }else if(type=="delete"){
            system.deleteOne(emailData).then((data)=>{
                res.send(data);
            })
        }
    }
}